import React,{Component} from "react";
import Header from "./Header/Header"
import List from "./List/List"
class CommentIndex extends Component{
    state={
        list:[
            {title:'111',desc:'222'},
            {title:'333',desc:'222'},
        ]
    }
    // 列表
    updateList=(msg)=>{
        const list=[...this.state.list]
        list.push(msg)
        this.setState({
            list
        })
    }

    // 删除
    del=(index)=>{
        this.state.list.splice(index,1)
        this.setState({
            list:this.state.list
        })
    }
        render(){
            return(<>
        <h2 style={{display:"flex",justifyContent:"center"}}>案例-发表评论</h2>
     
            <Header updateList={this.updateList} />
            <List list={this.state.list} del={this.del}/>
            </>)
        }
}



export default CommentIndex